#include "dialog.h"
#include "ui_dialog.h"

Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::Dialog)
{
    ui->setupUi(this);


}

Dialog::~Dialog()
{
    delete ui;
}

void Dialog::closeEvent(QCloseEvent *e)
{
    QMessageBox::StandardButton isok=QMessageBox::question(this,"关闭窗口","是否关闭");
    if(isok==QMessageBox::Yes)
    {
        e->accept();

    }
    else
    {
        e->ignore();
    }

}


void Dialog::on_pushButton_clicked()
{
    for(int i=0;i<MAXSIZE;i++)
    {
        Worker[i]=new workerthread();

    }
    for(int i=0;i<MAXSIZE;i++)
    {
        Worker[i]->receiveSlot(true);
        Worker[i]->start();
    }
    ui->pushButton->setDisabled(true);
    ui->pushButton_2->setDisabled(false);


}


void Dialog::on_pushButton_2_clicked()
{

    for(int i=0;i<MAXSIZE;i++)
    {
        Worker[i]->receiveSlot(false);
        Worker[i]->exit();
        Worker[i]->wait();

    }
    ui->pushButton->setDisabled(false);
    ui->pushButton_2->setDisabled(true);

}

void Dialog::on_pushButton_3_clicked()
{

    this->close();
}
